package com.debai.mapper;

import com.debai.pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {
    @Insert("insert into user_table(user_name,user_password,position_id,admin_id) values(#{userName},#{userPassword},#{positionId},#{adminId})")
    int insert(User user);

    @Select("select * from user_table")
    List<User> selectAll();

    @Delete("delete from user_table where id=#{userId}")
    int delete(int userId);

    @Select("select * from user_table where user_name=#{userName}and user_password=#{userPassword}")
    User selectByAccountAndPassword(String userName, String userPassword);

    @Select("select * from user_table where id=#{userId}")
    User selectById(Integer userId);

    @Select("select * from user_table where user_name=#{userName}")
    User selectByName(String userName);
}
